package cn.itsource.celljava.system.employee.service.impl;

import cn.itsource.celljava.system.employee.domain.Employee;
import cn.itsource.celljava.system.employee.domain.EmployeeBo;
import cn.itsource.celljava.system.employee.mapper.EmployeeMapper;
import cn.itsource.celljava.system.employee.service.IEmployeeService;
import cn.itsource.celljava.base.service.impl.BaseServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xmz
 * @since 2023-01-20
 */
@Service
public class EmployeeServiceImpl extends BaseServiceImpl<Employee> implements IEmployeeService {

    private final EmployeeMapper employeeMapper;
    public EmployeeServiceImpl(EmployeeMapper employeeMapper){
        this.employeeMapper = employeeMapper;
    }

    @Override
    public List<Employee> findAllBo() {
        List<EmployeeBo> all = employeeMapper.findAllBo();
        List<Employee> employees = new ArrayList<>();
        for (EmployeeBo one : all) {
            Employee employee = new Employee();
            //将原始对象中的值复制到新对象中
            BeanUtils.copyProperties(one,employee);
            employees.add(employee);
        }
        return employees;
    }

}
